--
-- @Author:      feilong
-- @DateTime:    2019-11-29 14:02:03
-- @Description: 游戏对象
local GameDef = require("GameDef")
local Game = import("manager.Game")

local GameManager = class("GameManager")

--构造函数
function GameManager:ctor(node_message)
	self.node_message = node_message
	self.game_list = {}
	self.user_game = {} --user所有在game
end


function GameManager:createGame(table_id)
	local game = Game.new(table_id)	
	self.game_list[table_id] = game
	return game
end

function GameManager:removeGame(table_id)
	self.game_list[table_id] = nil
end

function GameManager:getGame(table_id)
	return self.game_list[table_id]
end

function GameManager:addGame(game)
	self.game_list[game.table_id] = game
end

function GameManager:setUserGame(user_id, game)
	self.user_game[user_id] = game
end

function GameManager:removeUser(user_id)
	self.user_game[user_id] = nil
end

function GameManager:getGameByUserId(user_id)
	return self.user_game[user_id]
end

return GameManager